﻿#region The MIT License (MIT)
// The MIT License (MIT)
// Copyright (c) 2010 - 2013 Sovacode LLC
// 
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated 
// documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to the following conditions:
// 
// The above copyright notice and this permission notice shall be included in all copies or substantial portions
// of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
// BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
#endregion

/* Importing namespaces */
using System.Collections.Generic;
using System.Text;
using Sovacode.RubiksCube.Common.ViewModel;

namespace Sovacode.DemoApp.ViewModel
{
    public sealed class CommandsViewModel : BasicViewModel.ChildsHolderViewModel
    {
        #region Private Fields

        private string _message;

        #endregion

        #region Public Properties

        /// <summary>
        /// Message to show in dialog windows
        /// </summary>
        public string Message
        {
            get { return _message; }
            set
            {
                _message = value;

                OnPropertyChanged(() => Message);
            }
        }

        /// <summary>
        /// Gets the invalid view model commands.
        /// </summary>
        /// <value>The invalid view model commands.</value>
        public string InvalidViewModelCommands
        {
            get { return string.Format("Total Invalid Commands: '{0}'", InvalidCommandsCount); }
        }

        /// <summary>
        /// Gets the total view model commands.
        /// </summary>
        /// <value>The total view model commands.</value>
        public string TotalViewModelCommands
        {
            get { return string.Format("Total Commands: '{0}'", CommandsCount); }
        }

        /// <summary>
        /// Gets the valid view model commands.
        /// </summary>
        /// <value>The valid view model commands.</value>
        public string ValidViewModelCommands
        {
            get { return string.Format("Total Valid commands: '{0}'", ValidCommandsCount); }
        }

        #endregion

        #region Commands

        /// <summary>
        /// Shows all commands.
        /// </summary>
        private void ShowAllCommands()
        {
            ShowInformation(this.AllCommands, "All commands:");
        }

        /// <summary>
        /// Shows the valid commands.
        /// </summary>
        private void ShowValidCommands()
        {
            ShowInformation(this.ValidCommands, "All valid commands:");
        }

        // ReSharper disable InconsistentNaming
        private void WibblyWobblyTimeyWimey_Stuff()
        // ReSharper restore InconsistentNaming
        {
            ShowMessage("Wibbly Wobbly Timey Wimey...Stuff");
        }

        #endregion

        /// <summary>
        /// Method where the commands should be registered.
        /// </summary>
        protected override void RegisterCommands()
        {
            base.RegisterCommands();

            RegisterCommand(Commands.Const.CommandsView.WibblyWobblyTimeyWimey_Stuff, o => WibblyWobblyTimeyWimey_Stuff());
            RegisterCommand(Commands.Const.CommandsView.ShowMessageFromTextBox, o => ShowMessage(Message), p => !string.IsNullOrWhiteSpace(Message));
            RegisterCommand(Commands.Const.CommandsView.ShowAllCommands, o => ShowAllCommands());
            RegisterCommand(Commands.Const.CommandsView.ShowValidCommands, o => ShowValidCommands());
        }


        /// <summary>
        /// Gets the description file.
        /// </summary>
        /// <value>The description file.</value>
        protected override string DescriptionFile
        {
            get { return "CommandsDescription.txt"; }
        }
    }
}